<?php session_start();

	include("SVsystem/config/dbconfig.php"); ////////setup
include "SVsystem/class/remoteFunctions.php";
includeCommonClass('formulario');
	include("SVsystem/class/email.php");
	$mail = new email();

	$tool = new formulario();
	$tool->autoconexion();


	if(isset($_REQUEST['r-ntransacc'])){

			if(empty($_REQUEST['r-fecha'])){ $_POST['r-fecha'] = date("Y-m-d");

			}else{

			 	$fechi = explode("/",$_REQUEST['r-fecha']);
				$_POST['r-fecha'] = $fechi[2].'-'.$fechi[1].'-'.$fechi[0];

			}



			$montop = $_POST['r-monto'];
			$fechap = $_POST['r-fecha'];

			$_POST['r-cliente_id'] = $_SESSION['CLIENTE_ID'];
			$tool->insert_data("r","-","pago",$_POST);


			$bancop = $tool->simple_db("select banco from pago_datos where id = '{$_POST['r-dato_id']}' ");


			///////////////////
			/////user
			$dat4 = $tool->simple_db("SELECT DISTINCT
											  c.nombre,
											  c.email,
											  (SELECT preferencias.subject_pay_user FROM preferencias) AS etitulo,
											  (SELECT preferencias.pay_user FROM preferencias) AS emensaje
											FROM
											  cliente c
											WHERE
											  id = '{$_SESSION['CLIENTE_ID']}' AND
											  activo = 1");


			$usern = $dat4['nombre'];
			$usere = $dat4['email'];
			$concepton = $_REQUEST['r-comentario'];

			$nombre_email   = $dat4['nombre'];
  			$email_send 	= $dat4['email'];

			 $original  = array('$nombre_email', '$email_send','$usern','$usere', '$concepton','$bancop','$montop','$fechap');
			 $reemplazo = array($nombre_email, $email_send, $usern, $usere, $concepton, $bancop, $montop, $fechap);

			  $email_subject = str_replace($original, $reemplazo, $dat4['etitulo']);
			  $email_content = str_replace($original, $reemplazo, $dat4['emensaje']);


			include('email.php');

			/////////admin
			$dat4 = $tool->simple_db("SELECT subject_pay_admin as titulo,pay_admin AS mensaje
														FROM preferencias
															");


							      $email_subject = str_replace($original, $reemplazo, $dat4['titulo']);
			  					  $email_content = str_replace($original, $reemplazo, $dat4['mensaje']);


			unset($nombre_email);
  			unset($email_send);


			include('email.php');


			//////////////////

			$tool->redirect('SV-popup-form-pago-ok.php');

	}else{

		$pagodata = $tool->estructura_db("select banco,nombre,rif,ncuenta from pago_datos ");
        $data = $tool->simple_db("select popup_style from preferencias");

	}


 ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Datos de Pago</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="http://www.svcmscentral.com/estilos-popups/<?php echo $data ?>" rel="stylesheet" type="text/css">


<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


//-->
</script>
</head>

<body class="body-popup">
<div class="popup-titulo">Datos de Pago</div>
<div class="popup-instrucciones">
Estos son los datos de nuestras cuentas bancarias para que usted realice su pago v&iacute;a transferencia online o dep&oacute;sito.</div>

<form action="" method="post" name="form1">
 <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" id="interna">
  <tr>
   <td align="center">

<?php for($j=0;$j<count($pagodata);$j++){ ?>
            <div class="pago-container">
            <div class="pago-banco"><b>Banco:</b> <?php echo $pagodata[$j]['banco'] ?></div>
            <div class="pago-numero"><b>Cuenta:</b> <?php echo $pagodata[$j]['ncuenta'] ?></div>
            <div class="pago-nombre"><b>Beneficiario:</b> <?php echo $pagodata[$j]['nombre'] ?></div>
			<div class="pago-nombre"><b>C.I.:</b> <?php echo $pagodata[$j]['rif'] ?></div>
            </div>

            <?php }?></td>
  </tr>
  <tr>
   <td >

<center><input name="Submit2" type="button" class="popup-form-button" value="Cerrar Ventana" onClick="window.close();"></center>
  </td>
  </tr>
 </table>
</form>
</body>
</html>